<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>test无缝滚动</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            position: relative;
            margin: 30px auto;
            width: 600px;
            height: 200px;
            border: 1px red solid;
            overflow: hidden;
        }

        .box>ul {
            position: absolute;
            top: 0;
            left: 0;
            width: 300%;
            height: 100%;
            list-style: none;
        }

        .box>ul>li {
            float: left;
        }

        .box>ul>li>img {
            /* 清除垂直浮动 */
            vertical-align: top;
        }
    </style>
</head>
<script>
    window.onload = function () {
        function $(selecter) {
            return document.querySelector(selecter)
        }
        var moveVal = 0;
        var timer = null
        function fn() {
            moveVal -= 3
            if (moveVal <= -4 * 300) {
                moveVal = 0
            }
            $('ul').style.left = moveVal + 'px'
        }
        timer = setInterval(fn, 30)
        $('.box').onmouseover = function () {
            clearInterval(timer)
        }
        $('.box').onmouseout = function () {
            timer = setInterval(fn, 30)
        }
    }
</script>

<body>
    <div class="box">
        <ul>
            <li><img src="./01.jpg" alt="图片"></li>
            <li><img src="./02.jpg" alt="图片"></li>
            <li><img src="./03.jpg" alt="图片"></li>
            <li><img src="./04.jpg" alt="图片"></li>
        </ul>
    </div>
</body>

</html>